<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.CreateHardwareTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <p:panel header="Hardware">
                    <p:panelGrid columns="2">
                        <f:facet name="header">
                            <h:outputText value="Cadastro de Novo Hardware" /> 
                        </f:facet>
                        <f:facet name="footer" >
                            <p:dataTable value="#{supplyController.items}" var="item"   id="supply"  style="border:solid 1px">
                                <f:facet name="header">
                                    <h2>List</h2> 
                                </f:facet>

                                <f:facet name="footer">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{bundle.ListSupplyTitle_numer}"/>
                                    </f:facet>
                                    <h:outputText value="#{item.ID}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{bundle.ListSupplyTitle_address}"/>
                                    </f:facet>
                                    <h:outputText value="#{item.address.toString()}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{bundle.ListSupplyTitle_name}"/>
                                    </f:facet>
                                    <h:outputText value="#{item.name}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{bundle.ListSupplyTitle_ID}"/>
                                    </f:facet>
                                    <h:outputText value="#{item.ID}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="&nbsp;"/>
                                    </f:facet>
                                    <p:commandButton action="#{supplyController.AddSuplyOnProduct(item.ID)}" value="ADD"/>

                                </p:column>
                            </p:dataTable>
                            <h:outputText value="WebApplication      " />  <p:commandButton action="#{hardwareController.create}" value="#{bundle.CreateHardwareSaveLink}" />
                        </f:facet>
                        <h:outputLabel value="#{bundle.CreateHardwareLabel_description}" for="description" />
                        <h:inputText id="description" value="#{hardwareController.selected.description}" title="#{bundle.CreateHardwareTitle_description}" >
                            <p:ajax update="supply"  />
                        </h:inputText>    

                        <h:outputLabel value="#{bundle.CreateHardwareLabel_assembly}" for="assembly" />
                        <h:inputText id="assembly" value="#{hardwareController.selected.assembly}" title="#{bundle.CreateHardwareTitle_assembly}" />
                        <h:outputLabel value="#{bundle.CreateHardwareLabel_price}" for="price" />
                        <h:inputText id="price" value="#{hardwareController.selected.price}" title="#{bundle.CreateHardwareTitle_price}" />

                    </p:panelGrid>
                    <br />

                    <br />
                    <br />
                    <h:commandLink action="#{hardwareController.prepareList}" value="#{bundle.CreateHardwareShowAllLink}" immediate="true"/>
                    <br />
                    <br />
                    <h:link outcome="/home" value="#{bundle.CreateHardwareIndexLink}"/>

                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
